package com.lst.api.vo;

import com.lst.api.entity.AssetsCreditInfo;
import com.lst.api.exception.RequestParamErrorException;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 资产信息中的信用信息
 *
 * @author Frank
 * @date 2019-12-30 10:31:37
 * @version: V1.0
 */
@Data
@NoArgsConstructor
public class AssetsCreditInfoVo implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(name = "creditCardSum", value = "信用卡张数", required = true, dataType = "Integer")
    private Integer creditCardSum;

    @ApiModelProperty(name = "creditCardTotalQuota", value = "信用卡总额度，单位元", required = true, dataType = "Double")
    private Double creditCardTotalQuota;

    @ApiModelProperty(name = "creditCardTotalUseQuota", value = "信用卡已使用额度，单位元", required = true, dataType = "Double")
    private Double creditCardTotalUseQuota;

    public AssetsCreditInfoVo(AssetsCreditInfo assetsCreditInfo) {
        if (assetsCreditInfo == null) {
            return;
        }
        this.creditCardSum = assetsCreditInfo.getCreditCardSum();
        this.creditCardTotalQuota = assetsCreditInfo.getCreditCardTotalQuota();
        this.creditCardTotalUseQuota = assetsCreditInfo.getCreditCardTotalUseQuota();
    }

    public void check() {
        boolean check = this.creditCardSum != null
                && this.creditCardTotalQuota != null
                && this.creditCardTotalUseQuota != null;
        if (!check) {
            throw new RequestParamErrorException("AssetsCreditInfoVo请求参数不合法！");
        }
    }
}